package com.viettel.synctask;

import android.os.AsyncTask;
import android.util.Log;

import com.viettel.data.ApplyJobFetcher;
import com.viettel.rmsmobile.ApplyJobActivity;
import com.viettel.rmsmobile.MainActivity;

public class ApplyJobSyncTask extends AsyncTask<Object, Boolean, String> {

	ApplyJobActivity applyJobActivity;

	public ApplyJobSyncTask(ApplyJobActivity applyJobActivity){
		this.applyJobActivity = applyJobActivity;
	}
	@Override
	protected String doInBackground(Object... params) {
		//applyJobActivity = (ApplyJobActivity) params[0];
		String recruitmentAnouncementId = (String) params[0];
		String currentSalary = (String) params[1];
		String disireSalary = (String) params[2];
		String place = (String) params[3];
		ApplyJobFetcher applyJobFetcher = new ApplyJobFetcher(MainActivity.portalUser.getEmail(),
				recruitmentAnouncementId, currentSalary, disireSalary, place);
		return applyJobFetcher.getResultApply();
	}

	@Override
	protected void onPostExecute(String response) {
		try {
			applyJobActivity.notifyResult(response);
		} catch (Exception e) {
			Log.d("Error: ", " " + e.getMessage());
		}
		super.onPostExecute(response);
	}	
}
